package Solutions

type empty struct{}

func modifiedList(nums []int, head *ListNode) *ListNode {
	mp := make(map[int]empty, len(nums))
	for _, v := range nums {
		mp[v] = empty{}
	}
	hp := ListNode{
		Next: head,
	}
	h := &hp
	for h.Next != nil {
		child := h.Next
		if _, ok := mp[child.Val]; ok {
			h.Next = child.Next
		} else {
			h = h.Next
		}
	}
	return hp.Next
}
